<template>
	<div class="direct-storage-info">
		<div class="main_content">
			<div class="main_content_title">
				<div class="left">
					<span>{{ propUpType === 'add' ? $t('publicBtn.add') : propUpType === 'edit' ? $t('publicBtn.edit') :
						$t('publicBtn.detail') }}</span>
					<template v-for="(item, index) in $route.meta.title">
						<span v-if="languageId === item.langId">{{ item.name }}</span>
					</template>
				</div>
				<div class="right" />
			</div>
			<div class="main_content_con">
				<el-form ref="info" :model="info" :rules="rules" label-width="100px" class="demo-ruleForm">
					<div class="content_info">
						<template v-if="propUpType !== 'detail'">
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.supplier')" prop="supplierId">
										<el-select v-model="info.supplierId" filterable :placeholder="$t('placeholderTip.pSelect')"
											style="width:100%">
											<el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id" />
										</el-select>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.warehousingTotalQuantity')">
										<el-input readonly :value="info.totalNum" :placeholder="$t('placeholderTip.bringOut')" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.inventoryIntoAmt')">
										<el-input readonly :value="info.intoAmt" :placeholder="$t('placeholderTip.bringOut')" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.inventoryType')">
										<el-input readonly :value="info.classifyNum" :placeholder="$t('placeholderTip.bringOut')" />
									</el-form-item>
								</el-col>
							</el-row>
							<!-- <el-row :gutter="24">
								<el-col :span="8">
									<el-form-item label="报关费用">
										<el-input readonly v-model="info.code" :placeholder="$t('placeholderTip.enter')" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="运输费用">
										<el-input readonly v-model="info.code" :placeholder="$t('placeholderTip.enter')" />
									</el-form-item>
								</el-col>
							</el-row> -->
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('publicFormLabel.remark')">
										<el-input v-model="info.remark" type="textarea" :placeholder="$t('placeholderTip.enter')" />
									</el-form-item>
								</el-col>
							</el-row>
							<div class="line"></div>
							<div class="contentInfo">
								<div class="header">
									<div class="title">{{ $t('text.detailsOfIncomingProducts') }}</div>
									<div class="btn">
										<el-button type="primary" size="mini" @click="addData">{{
											$t('publicBtn.add') }}</el-button>
										<el-button type="success" size="mini" @click="addLeadIn">{{ $t('publicBtn.toLeadInto') }}</el-button>
									</div>
								</div>
								<el-table :data="info.intoInventories" border style="width: 100%">
									<el-table-column prop="code" :label="$t('formLabel.partNumber')" align="center" />
									<el-table-column prop="name" :label="$t('formLabel.partName')" align="center" />
									<el-table-column prop="alias" :label="$t('formLabel.partAnotherName')" align="center" />
									<el-table-column prop="brand" :label="$t('publicFormLabel.brandName')" align="center" width="200px" />
									<el-table-column prop="specs" :label="$t('formLabel.specification')" align="center" />
									<el-table-column prop="unit" :label="$t('formLabel.unit')" align="center" />
									<el-table-column :label="$t('formLabel.retailPrice')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.retailPrice'"
												:rules="rules.retailPrice">
												<el-input type="number" v-model="scope.row.retailPrice" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.claiMprice')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.claimPrice'"
												:rules="rules.claimPrice">
												<el-input type="number" v-model="scope.row.claimPrice" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.insurancePrice')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.insurePrice'"
												:rules="rules.insurePrice">
												<el-input type="number" v-model="scope.row.insurePrice" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.wholesalePrice')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px"
												:prop="'intoInventories.' + scope.$index + '.wholesalePrice'" :rules="rules.wholesalePrice">
												<el-input type="number" v-model="scope.row.wholesalePrice"
													:placeholder="$t('placeholderTip.enter')" style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.purchasePrice')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.cost'"
												:rules="rules.cost">
												<el-input type="number" v-model="scope.row.cost" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.quantityArrival')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.arriveNum'"
												:rules="rules.arriveNum">
												<el-input v-model="scope.row.arriveNum" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column prop="intoNum" :label="$t('publicFormLabel.intoNum')" align="center" />
									<el-table-column :label="$t('formLabel.disqualificationNumber')" align="center" width="180px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px"
												:prop="'intoInventories.' + scope.$index + '.unqualifiedNum'" :rules="rules.unqualifiedNum">
												<el-input v-model="scope.row.unqualifiedNum" :placeholder="$t('placeholderTip.enter')"
													style="width:93%"></el-input>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.warehouseName')" align="center" width="200px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.warehouseId'"
												:rules="rules.warehouseId">
												<el-select style="width:93%" v-model="scope.row.warehouseId" filterable
													:placeholder="$t('placeholderTip.pSelect')" @change="getPositionList(scope.$index, $event)">
													<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
												</el-select>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.storageLocation')" align="center" width="200px">
										<template slot-scope="scope">
											<el-form-item label=" " label-width="2px" :prop="'intoInventories.' + scope.$index + '.positionId'"
												:rules="rules.positionId">
												<el-select style="width:93%" v-model="scope.row.positionId" filterable
													:placeholder="$t('placeholderTip.pSelect')">
													<el-option v-for="item in scope.row.positionList" :key="item.id" :label="item.name"
														:value="item.id" />
												</el-select>
											</el-form-item>
										</template>
									</el-table-column>
									<el-table-column fixed="right" :label="$t('publicFormLabel.operate')" align="center" width="80px">
										<template slot-scope="scope">
											<el-button @click="deleteRow(scope.$index)" type="text" size="small">{{
												$t('publicBtn.delete') }}</el-button>
										</template>
									</el-table-column>
								</el-table>
							</div>
						</template>
						<template v-else>
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('publicFormLabel.warehouseNumber')">
										<el-input readonly :value="info.intoOrder" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.supplier')" prop="supplierId">
										<el-input readonly :value="info.supplierName" />
									</el-form-item>
								</el-col>
							</el-row>
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.warehousingTotalQuantity')">
										<el-input readonly :value="info.totalNum" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.inventoryIntoAmt')">
										<el-input readonly :value="info.intoAmt" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item :label="$t('formLabel.inventoryType')">
										<el-input readonly :value="info.classifyNum" />
									</el-form-item>
								</el-col>
							</el-row>
							<!-- <el-row :gutter="24">
								<el-col :span="8">
									<el-form-item label="报关费用">
										<el-input readonly v-model="info.code" :placeholder="$t('placeholderTip.enter')" />
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="运输费用">
										<el-input readonly v-model="info.code" :placeholder="$t('placeholderTip.enter')" />
									</el-form-item>
								</el-col>
							</el-row> -->
							<el-row :gutter="24">
								<el-col :span="8">
									<el-form-item :label="$t('publicFormLabel.remark')">
										<el-input readonly v-model="info.remark" type="textarea" />
									</el-form-item>
								</el-col>
							</el-row>
							<div class="line"></div>
							<div class="contentInfo">
								<div class="header">
									<div class="title">{{ $t('text.detailsOfIncomingProducts') }}</div>
								</div>
								<el-table :data="info.intoInventories" border style="width: 100%">
									<el-table-column prop="code" :label="$t('formLabel.partNumber')" align="center" />
									<el-table-column prop="name" :label="$t('formLabel.partName')" align="center" />
									<el-table-column prop="alias" :label="$t('formLabel.partAnotherName')" align="center" />
									<el-table-column prop="brand" :label="$t('publicFormLabel.brandName')" align="center" width="160px" />
									<el-table-column prop="specs" :label="$t('formLabel.specification')" align="center" />
									<el-table-column prop="unit" :label="$t('formLabel.unit')" align="center" />
									<el-table-column :label="$t('formLabel.retailPrice')" align="center">
										<template slot-scope="scope">
											{{ scope.row.retailPrice }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.claiMprice')" align="center">
										<template slot-scope="scope">
											{{ scope.row.claimPrice }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.insurancePrice')" align="center">
										<template slot-scope="scope">
											{{ scope.row.insurePrice }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.wholesalePrice')" align="center">
										<template slot-scope="scope">
											{{ scope.row.wholesalePrice }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.purchasePrice')" align="center">
										<template slot-scope="scope">
											{{ scope.row.cost }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.quantityArrival')" align="center">
										<template slot-scope="scope">
											{{ scope.row.arriveNum }}
										</template>
									</el-table-column>
									<el-table-column prop="intoNum" :label="$t('publicFormLabel.intoNum')" align="center" />
									<el-table-column :label="$t('formLabel.disqualificationNumber')" align="center">
										<template slot-scope="scope">
											{{ scope.row.unqualifiedNum }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.warehouseName')" align="center">
										<template slot-scope="scope">
											{{ scope.row.warehouseName }}
										</template>
									</el-table-column>
									<el-table-column :label="$t('formLabel.storageLocation')" align="center">
										<template slot-scope="scope">
											{{ scope.row.positionName }}
										</template>
									</el-table-column>
								</el-table>
							</div>
						</template>
					</div>
				</el-form>
				<div class="footerBtn">
					<el-button @click="getCancle">{{ propUpType !== 'detail' ? $t('el.popconfirm.cancelButtonText') :
						$t('el.popconfirm.close') }}</el-button>
					<el-button v-if="propUpType !== 'detail'" type="primary" @click="addSubmitForm"
						v-loading.fullscreen.lock="fullscreenLoading">{{ $t('el.popconfirm.confirmButtonText') }}</el-button>
				</div>
			</div>
		</div>
		<!-- 添加配件 -->
		<attachmentModel ref="attachmentModel"></attachmentModel>

		<!-- 导入 -->
		<leadIn ref="leadIn" :title="title" :template_type="1"></leadIn>

		<!-- 仓库 -->
		<warehouseQuery ref="warehouseQuery"></warehouseQuery>

		<!-- 配件信息 -->
		<div v-if="partsVisible">
			<el-dialog :title="$t('text.accessoriesInformationQuery')" :visible.sync="partsVisible" width="65%"
				:before-close="partsVisiblecloseDialog" custom-class="add_dialog" append-to-body>
				<div class="main_content_con_md">
					<el-table ref="qtable" v-loading="loading" :data="partsList" style="width:100%" tooltip-effect="dark"
						row-key="id" :tree-props="{ children: 'children' }" :default-expand-all="false"
						:select-on-indeterminate="true" :border="true" height="100%" highlight-current-row>
						<template v-for="(item, headerIndex) in partsTableConfig">
							<el-table-column v-if="item.show" :key="item.key" :column-key="item.key" :min-width="item.width"
								:show-overflow-tooltip="false" :resizable="item.resizable" :fixed="item.fixed" align="center">
								<template slot="header" slot-scope="scope">
									<div class="header_item">
										{{ item.label }}
									</div>
									<div v-if="showSearchFlag" class="search_box">
										<div v-if="item.searchEnable">
											<div class="input_box">
												<el-input v-model="item.value" size="mini" clearable :placeholder="$t('placeholderTip.enter')"
													:tabindex="headerIndex + 1 + ''" @keyup.enter.native="getPartsList" @clear="getPartsList" />
											</div>
										</div>
									</div>
								</template>
								<template slot-scope="scope">
									{{ scope.row[item.key] }}
								</template>
							</el-table-column>
						</template>
					</el-table>
				</div>
				<div class="pagination_box">
					<el-pagination :current-page="partsPagination.page" :page-sizes="[10, 20, 30, 50, 100]"
						:page-size="partsPagination.limit" layout="total, sizes, prev, pager, next, jumper"
						:total="partsPagination.total" @size-change="partsHandleSizeChange"
						@current-change="partsHandleCurrentChange" />
				</div>
				<span slot="footer" class="dialog-footer">
					<el-button @click="partsVisiblecloseDialog">{{ $t('publicBtn.close') }}</el-button>
				</span>
			</el-dialog>
		</div>
	</div>
</template>
<script>
import {
	getMaterialIntoInfo,
	setMaterialIntoSaveInto,
	getAssSupplierSelectList,
	getWarehousePositionSelectList,
	getAssWarehouseSelectList,
	getAssMaterialList,
	setMaterialIntoImportMaterialList
} from '@/api/parts-manager'
import defaultSettings from '@/settings'
import attachmentModel from '@/components/attachment-model'
import leadIn from '@/components/lead-in'
import warehouseQuery from '@/components/warehouse-query'

export default {
	name: '',
	components: {
		attachmentModel,
		leadIn,
		warehouseQuery
	},
	data() {
		return {
			BASE_IMG: defaultSettings.BASE_IMG,
			info: {
				supplierId: '',//供应商
				classifyNum: '',//采购种类
				totalNum: '',//采购总数
				intoAmt: '',//入库金额
				totalAmt: '', //总金额
				supplyAmt: '',//供货金额
				remark: '',//备注
				intoInventories: [],
			},
			warehouseList: [],//仓库
			supplierList: [],//供应商
			flag: true,
			rules: {
				supplierId: [
					{
						required: true,
						message: this.$t('placeholderTip.pSelect'),
						trigger: 'change'
					}
				],
				arriveNum: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				cost: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],

				unqualifiedNum: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				warehouseId: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				positionId: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				retailPrice: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				insurePrice: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				claimPrice: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
				wholesalePrice: [
					{
						required: true,
						message: this.$t('placeholderTip.enter'),
						trigger: 'blur'
					}
				],
			},
			pickerOptions: {
				disabledDate(time) {
					return time.getTime() < Date.now() - 8.64e7
				}
			},
			propUpType: '', // 'add' edit detail
			fullscreenLoading: false,
			loading: false,
			showSearchFlag: true, //配件信息搜索
			title: this.$t('text.accessoriesImport'),
			partsTableConfig: [], //配件字典表头
			partsList: [], //配件列表
			partsVisible: false, //配件信息
			partsPagination: {
				page: 1,
				limit: 20,
				total: 0
			}, //配件分页
		}
	},
	computed: {
		languageId() {
			// 固定语种ID  1:中文  2:英文 3:俄文 4:乌语
			return this.$store.getters.languageId
		},
	},
	watch: {
		'info.intoInventories': {
			handler: function (val) {
				if (val.length > 0) {
					if (this.propUpType === 'add') {
						var sumNumber = 0
						var number = []
						var amountNumber = 0
						var intoAmt = []
						var supplyAmt = []
						var supplyAmtNumber = 0
						this.info.intoInventories.map(i => {
							if (i.intoNum) {
								number.push(Number(i.intoNum))
							}
							// 入库数量：到货-不合格
							// if (i.arriveNum && i.unqualifiedNum) {
							// 	i.intoNum = Number(i.arriveNum) - Number(i.unqualifiedNum)
							// }
							// 入库数量=到货数量
							if (i.arriveNum) {
								i.intoNum = Number(i.arriveNum)
							}
							// 入库总金额 = 总金额
							if (i.intoNum && i.cost) {
								i.amount = Number(i.intoNum) * Number(i.cost)
								intoAmt.push(Number(i.amount))
							}
							// 供货金额 单价*到货数量
							if (i.cost && i.arriveNum) {
								var price = Number(i.cost) * Number(i.arriveNum)
								supplyAmt.push(Number(price))
							}
						})
						number.forEach(item => {
							sumNumber = sumNumber + item
						})
						intoAmt.forEach(item => {
							amountNumber = amountNumber + item
						})
						supplyAmt.forEach(item => {
							supplyAmtNumber = supplyAmtNumber + item
						})
						this.info.classifyNum = val.length//入库种类
						this.info.totalNum = sumNumber //入库数量
						this.info.intoAmt = amountNumber //入库总金额
						this.info.totalAmt = this.info.intoAmt //总金额
						this.info.supplyAmt = supplyAmtNumber//供货金额
					}
				}
			},
			deep: true
		}
	},
	mounted() {
		window._vm = this
		this.propUpType = this.$route.query.propUpType
		if (this.$route.query.propUpType === 'add') {
			this.getSupplierist()
			this.getWarehouseList()
		} else if (this.$route.query.id) {
			this.getInfo(this.$route.query.id)
		}
	},
	created() {
		console.log('created')
	},
	activated() { },

	destroyed() { },
	methods: {
		// 供应商
		getSupplierist() {
			getAssSupplierSelectList().then(res => {
				if (res.code === 200) {
					this.supplierList = res.data || []
				}
			})
		},
		// 仓库
		getWarehouseList() {
			getAssWarehouseSelectList().then(res => {
				if (res.code === 200) {
					this.warehouseList = res.data || []
				}
			})
		},
		// 根据仓库id 选择库位
		getPositionList(index, id) {
			var list = JSON.parse(JSON.stringify(this.info.intoInventories))
			list[index].positionList = []
			list[index].positionId = ''
			getWarehousePositionSelectList(id).then(res => {
				if (res.code === 200) {
					list[index].positionList = res.data || []
				}
			})
			this.info.intoInventories = list
		},
		// 添加明细按钮
		addData() {
			this.$refs.attachmentModel.getOpen()
		},
		// 处理配件列表选中的数据
		getCheckoutData(tar) {
			if (!this.flag) {
				this.info.intoInventories = []
			}
			var data = JSON.parse(tar)
			var obj = {
				materialId: data.id,
				code: data.code,
				name: data.name,
				alias: data.alias,
				brand: data.brandNames,
				specs: data.specs,
				unit: data.smallName,
				retailPrice: data.retailPrice,//零售价格
				insurePrice: data.insurePrice,//理赔价格
				claimPrice: data.claimPrice,//索赔价格
				wholesalePrice: data.wholesalePrice,//批发价格
				arriveNum: '',//到货数量
				intoNum: '',//入库数量
				cost: '',//采购单价
				unqualifiedNum: '',//不合格数
				positionId: '',//库位id
				warehouseId: '',//仓库id
				positionList: [],//库位
			}
			const checkId = (items, idToCheck) => {
				return items.filter(item => item.materialId === idToCheck).length > 0;
			}
			// 不重复 push数据
			if (!checkId(this.info.intoInventories, data.id)) {
				this.info.intoInventories.push(obj)
			}
			this.flag = true
		},

		// 调起导入弹框方法
		addLeadIn() {
			this.flag = false
			this.$refs.leadIn.getOpen()
		},
		// 配件信息
		getDataInfoVisible() {
			this.partsVisible = true
			this.partsTableConfig = [
				{
					key: 'code',
					label: this.$t('formLabel.partNumber'),
					searchType: 'text',
					searchField: 'code',
					show: true,
					searchEnable: true,
					// width: 150,
					value: ''
				},
				{
					key: 'name',
					label: this.$t('formLabel.partName'),
					searchType: 'text',
					searchField: 'name',
					show: true,
					// width: 150,
					searchEnable: true,
					value: ''
				},
				{
					key: 'alias',
					label: this.$t('formLabel.partAnotherName'),
					searchType: 'text',
					searchField: 'alias',
					show: true,
					searchEnable: false,
					// width: 150,
					value: ''
				},
				{
					key: 'brandNames',
					label: this.$t('publicFormLabel.brandName'),
					searchField: 'brandNames',
					show: true,
					searchEnable: false,
					searchType: 'text',
					value: ''
				},
				{
					key: 'specs',
					label: this.$t('formLabel.specification'),
					searchType: 'text',
					searchField: '',
					show: true,
					searchEnable: false,
					value: ''
				},
				{
					key: 'smallName',
					label: this.$t('formLabel.unit'),
					searchType: 'text',
					searchField: '',
					show: true,
					searchEnable: false,
					width: '',
					value: ''
				},
			]
			this.getPartsList() //配件接口获取列表
		},

		// 仓库信息查看弹框
		getWarehouseInfoVisible() {
			this.$refs.warehouseQuery.getOpen()
		},
		getPartsList() {
			var params = {
				page: this.partsPagination.page,
				limit: this.partsPagination.limit,
				status: 1
			}
			this.partsTableConfig.forEach(item => {
				if (item.searchEnable && item.value) {
					console.log('key : ' + item.key + '\n' + 'value : ' + item.value)
					if (item.searchType === 'timeRange') {
						params[item.searchField || item.key] = item.value.join(',')
					} else {
						params[item.searchField || item.key] = item.value
					}
				}
			})
			var searchObj = ''
			// // 筛选条件取值
			if (Object.keys(params).length > 0) {
				Object.keys(params).forEach(function (key, index) {
					if (index === 0) {
						// 第一个 不需要  '&'
						searchObj = searchObj.concat(`${key}=${params[key]}`)
					} else {
						searchObj = searchObj.concat('&' + `${key}=${params[key]}`)
					}
				})
			}
			this.loading = true
			getAssMaterialList(searchObj).then(res => {
				if (res.code === 200) {
					this.partsList = res.data.list || []
					this.partsPagination.limit = res.data.pageSize
					this.partsPagination.total = res.data.totalCount
					this.loading = false
				} else {
					this.loading = false
				}
			})
		},

		partsVisiblecloseDialog() {
			this.partsVisible = false
			this.partsList = []
		},


		//导入
		getToLeadData(FormDatas) {
			this.info.intoInventories = []
			// 导入接口 数据传参
			setMaterialIntoImportMaterialList(FormDatas)
				.then(res => {
					if (res.code === 200) {
						// 导入之后数据处理
						if (res.data) {
							var list = res.data
							this.info.intoInventories = list || []
							list.map((i, index) => {
								if (i.warehouseId) {
									getWarehousePositionSelectList(i.warehouseId).then(res => {
										if (res.code === 200) {
											i['positionList'] = res.data || []
											this.$set(this.info.intoInventories, index, i)
										}
									})
								}
							})
							// 关闭弹框
							this.$refs.leadIn.closeDialog()
						}
					}
				})
				.catch(err => {
					this.$refs.leadIn.getVisibleError(true, err)
				})
		},

		// 删除明细
		deleteRow(index) {
			this.info.intoInventories.splice(index, 1)
			this.$forceUpdate() // 强制跟新
		},
		// 提交
		addSubmitForm() {
			this.$refs['info'].validate(valid => {
				if (valid) {
					var obj = JSON.parse(JSON.stringify(this.info))
					if (obj.intoInventories.length === 0) {
						this.$message({
							showClose: true,
							message: this.$t('text.intoInventoriestipInfo'),
							type: 'warning'
						})
						return false
					}
					var params = obj
					this.fullscreenLoading = true
					if (this.propUpType === 'add') {
						setMaterialIntoSaveInto(params)
							.then(res => {
								if (res.code === 200) {
									this.$message({
										showClose: true,
										message: this.$t('text.addSucceedTip'),
										type: 'success'
									})
									this.fullscreenLoading = false
									this.getCancle()
								}
							})
							.catch(err => {
								this.fullscreenLoading = false
								console.log(err, 'err')
							})
					}
				} else {
					return false
				}
			})
		},
		// 详情
		getInfo(id) {
			const loading = this.$loading({
				lock: true,
				text: this.$t('text.loading'),
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			})
			getMaterialIntoInfo(id).then(res => {
				if (res.code === 200) {
					this.info = res.data
					loading.close()
				}
			}).catch(() => {
				loading.close()
			})
		},
		// 取消
		getCancle() {
			this.$store.state.tagsView.visitedViews.splice(
				this.$store.state.tagsView.visitedViews.findIndex(
					item => item.path === this.$route.path
				),
				1
			)
			this.$router.go(-1)
		},

		// 车型字典 分页
		partsHandleSizeChange(val) {
			this.partsPagination.limit = val
			this.getPartsList()
		},
		partsHandleCurrentChange(val) {
			this.partsPagination.page = val
			this.getPartsList()
		},
	}
}
</script>
<style lang="scss" scoped>
.direct-storage-info {
	height: 100%;
	width: 100%;
	padding: 20px;
	box-sizing: border-box;
	overflow: hidden;

	&>.main_content {
		width: 99.9%;
		height: 100%;

		&>.main_content_title {
			margin-bottom: 10px;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
		}

		.main_content_con {
			height: calc(100% - 40px);
			width: 100%;
			display: inline-block;
			border: 1px solid #dfe6ec;
			padding: 20px;


			&>.el-form {
				width: 100%;
				height: calc(100% - 40px);

				&>.content_info {
					width: 100%;
					height: 100%;
					overflow: hidden;
					overflow-y: auto;

					.line {
						height: 1px;
						border: 1px solid #ebeef5;
					}

					.el-table {
						::v-deep th {
							line-height: 40px;
							padding: unset;
							background-color: #f2f2f2;
						}
					}
				}


			}

			.footerBtn {
				width: 100%;
				display: flex;
				justify-content: center;
			}

			.cardBox {
				width: 104px;
				height: auto;
				float: left;
				position: relative;

				&>.name {
					text-align: center;
					color: #999;
					font-size: 12px;
				}
			}

			.el-button:hover,
			.el-button:focus {
				color: #000;
			}

			.contentInfo {
				margin-top: 22px;

				&>.header {
					margin-bottom: 22px;
					display: flex;
					justify-content: space-between;
					color: #606266;

					&>.title {
						font-size: 14px;
						font-weight: bold;
					}

				}
			}





		}
	}
}
</style>
<style lang="scss" scoped>
.main_content_con_md {
	width: 100%;
	height: calc(100% - 25px);
	overflow: auto;
	display: inline-block;

	.el-table {
		::v-deep .el-icon-arrow-right {
			font-weight: 600;
		}

		::v-deep .el-form-item__error {
			left: 5%;
		}

		::v-deep .el-table__header .el-checkbox {
			display: none !important;
		}

		::v-deep th {
			padding: unset;
			background-color: #f2f2f2;

			.header_item {
				height: 39px;
				line-height: 39px;
				display: flex;
				justify-content: center;
				align-items: center;

				&>.keySort {
					width: 23px;
					height: 21px;
					position: relative;
					display: inline-block;

					&>.el-icon-caret-top {
						position: absolute;
						top: 0;
						right: 0;
						left: 0;
						margin: auto;
						cursor: pointer;
					}

					&>.el-icon-caret-bottom {
						position: absolute;
						bottom: 0;
						right: 0;
						left: 0;
						margin: auto;
						cursor: pointer;
					}
				}
			}
		}
	}
}
</style>
<style lang="scss" scoped>
::v-deep .add_dialog {
	height: calc(100% - 30vh) !important;
	position: relative;

	.el-dialog__header {
		border-bottom: 1px solid #e4e4e4;
		text-align: left;
	}

	.el-dialog__body {
		height: calc(100% - 125px) !important;

	}

	.el-dialog__footer {
		border-top: 1px solid #e4e4e4;
		text-align: right;
	}

	.el-button:hover,
	.el-button:focus {
		color: #000;
	}
}
</style>
